package com.fitz.remote.handler;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelPipeline;
import lombok.extern.slf4j.Slf4j;

/**
 * @author fitz 2020-5-15 15:35
 */
@Slf4j
public class ConnectionListener implements ChannelFutureListener {
    public ConnectionListener() {
    }

    @Override
    public void operationComplete(ChannelFuture channelFuture) throws Exception {
        if (!channelFuture.isSuccess()){
            log.error("连接失败,尝试重连");

        }else {
            log.info("连接成功～");
            DynamicTriggerHandler dynamicTriggerHandler = new DynamicTriggerHandler();
            ChannelPipeline pipeline = channelFuture.channel().pipeline();
            pipeline.addLast(DynamicTriggerHandler.class.getSimpleName(), dynamicTriggerHandler);
        }
    }
}
